Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

element-resize-detector

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-resize-detector

Resize event emitter for elements.

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
increased by12.45%
Maintainers
1
Weekly downloads
 
Created

What is element-resize-detector?

The element-resize-detector npm package is a utility for detecting changes in the size of HTML elements. It provides a way to listen for resize events on any DOM element, which can be useful for responsive design, dynamic content adjustments, and more.

What are element-resize-detector's main functionalities?

Basic Resize Detection

This feature allows you to listen for resize events on a specific DOM element. When the element is resized, the provided callback function is executed.

const elementResizeDetectorMaker = require('element-resize-detector');
const erd = elementResizeDetectorMaker();

const element = document.getElementById('myElement');
erd.listenTo(element, function(element) {
  console.log('Element resized:', element);
});

Unlisten to Resize Events

This feature allows you to stop listening to resize events on a specific DOM element. This can be useful for cleanup or when the resize detection is no longer needed.

const elementResizeDetectorMaker = require('element-resize-detector');
const erd = elementResizeDetectorMaker();

const element = document.getElementById('myElement');

function onResize(element) {
  console.log('Element resized:', element);
}

erd.listenTo(element, onResize);

// Later, if you want to stop listening to resize events
erd.uninstall(element);

Batch Listening

This feature allows you to listen for resize events on multiple elements at once. The provided callback function is executed whenever any of the elements are resized.

const elementResizeDetectorMaker = require('element-resize-detector');
const erd = elementResizeDetectorMaker();

const elements = document.querySelectorAll('.resize-listen');

function onResize(element) {
  console.log('Element resized:', element);
}

elements.forEach(element => erd.listenTo(element, onResize));

Other packages similar to element-resize-detector

FAQs

Package last updated on 14 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc